// -*- mode: c++ -*-
#ifndef __transition_h_
#define  __transition_h_
#include <ostream>
#include <vector>
#include <string>

#include "defines.h"


typedef std::vector<std::string> strvec;
class TransitionTarget;
class Transition
{
 public: 
  enum ttype {EXTERNAL, INTERNAL};

  Transition(std::string sid, std::string targetid="", std::string event = "", 
	     std::string cond = "", std::string stype="external");
  virtual ~Transition();

  strvec targetids;
  std::string sourceid;
  std::string event;
  std::string cond;
  std::vector<TransitionTarget*> targets;
  ttype type;


  std::string& getEvent(void) 
    {
      return event;
    }

  friend std::ostream &operator<<(std::ostream& cout, Transition *obj)
  {
      strvec::iterator i;
      if (obj)
      {
	  cout << obj->sourceid << " -> " ;
	  for(i=obj->targetids.begin(); i!=obj->targetids.end(); ++i)
	      cout << (*i) << " ";
	  cout << std::endl;
      }
    return cout;
  }

  friend std::ostream &operator<<(std::ostream& cout, const Transition &obj)
  {
      strvec::const_iterator i = obj.targetids.begin();
      cout << obj.sourceid << " -> ";
      while (i != obj.targetids.end())
	  cout << *i++ << " ";
      //showSequence(obj.targetids);
      //cout << std::endl;
      return cout;
  }

  void exec(void);
};
#endif
